package collection;

import java.util.Arrays;
import java.util.List;

/**
 * 数组转换为集合
 */
public class ArrayToList {
    public static void main(String[] args) {
        String[] array ={"one","two","three","fore","five"};
        System.out.println(Arrays.toString(array));

         //数组转换为集合
        List<String> list =Arrays.asList(array);
        System.out.println(list);

        //改数组的内容，集合跟着改变
        array[1]="xw";
        System.out.println(Arrays.toString(array));
        System.out.println(list);

        //改集合的内容，数组也跟着改变
        list.set(2,"lst");
        System.out.println(Arrays.toString(array));
        System.out.println(list);

       //给集合添加/删除元素相当于给数组添加/删除元素
        //而数组是定长的，不能改变
        list.add("gg");

    }
}
